package com.learning.jquizenglish.network.connection;

/**
 * Class to create an exception as required with error code and exception type as defined in
 * {@link ExceptionType}. This class extends the default {@link Exception} class with 3 new
 * parameters such as <code>Exception type and error code</code>.
 */
public class JsonPaserExceptions extends Exception {
    private static final long serialVersionUID = -46634463625548954L;
    private final String errorCode;

    /**
     * Constructs a new exception with null as its detail message.
     */
    public JsonPaserExceptions() {
        super();
        this.errorCode = null;
    }


    /**
     * Constructs a new exception with the specified exceptionType, errorCode, detailMessage,
     * errorText and a cause indicated by throwable.
     * 
     * @param exceptionType Exception Type defined in {@link ExceptionType}
     * @param errorCode Error code defined in Http standard error codes or it can be from Server.
     * @param detailMessage Detail message to fetch through getMessage() of {@link Exception}
     * @param throwable throwable as a cause as defined in {@link Exception} class.
     */
    public JsonPaserExceptions(String errorCode, String detailMessage, Throwable throwable) {
        super(detailMessage, throwable);
        this.errorCode = errorCode;
    }

    /**
     * Constructs a new exception with the specified exceptionType, errorCode, detailMessage,
     * errorText.
     * 
     * @param exceptionType Exception Type defined in {@link ExceptionType}
     * @param errorCode Error code defined in Http standard error codes or it can be from Server.
     * @param detailMessage Detail message to fetch through getMessage() of {@link Exception}
     */
    public JsonPaserExceptions(String errorCode, String detailMessage) {
        super(detailMessage);
        this.errorCode = errorCode;
    }

    /**
     * Constructs a new exception with the specified exceptionType, errorCode, detailMessage,
     * errorText and a cause indicated by throwable.
     * 
     * @param throwable A cause as defined in {@link Exception} class constructor.
     */
    public JsonPaserExceptions(Throwable throwable) {
        super(throwable);
        this.errorCode = null;
    }


    /**
     * Method to get error code for this exception, which is specified while constructing the
     * exception
     * 
     * @return errorCode as specified in constructor
     */
    public String getErrorCode() {
        return errorCode;
    }

}
